/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import accesodatos.Costos;
import accesodatos.Departamento;

/**
 *
 * @author Ana Maria
 */
public class DemandaDept extends javax.swing.JInternalFrame {

    boolean porAño,  porMes; 
    String año,mes;   
    /**
     * Creates new form DemandaDept
     */
    public DemandaDept() {
        initComponents();
        grupoTipo.add(rb_barra);
        grupoTipo.add(rb_pastel);
        
        boxAño.setEnabled(false);
        boxMes.setEnabled(false);
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        grupoTipo = new javax.swing.ButtonGroup();
        jPasswordField1 = new javax.swing.JPasswordField();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        checkAño = new javax.swing.JCheckBox();
        checkMes = new javax.swing.JCheckBox();
        boxAño = new javax.swing.JComboBox();
        boxMes = new javax.swing.JComboBox();
        buttConsultar = new javax.swing.JButton();
        buttSalir = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        rb_pastel = new javax.swing.JRadioButton();
        rb_barra = new javax.swing.JRadioButton();

        jPasswordField1.setText("jPasswordField1");

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setText("Regiones del pais de mas demanda de Servicios");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Fecha"));

        checkAño.setText("Por año");
        checkAño.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkAñoActionPerformed(evt);
            }
        });

        checkMes.setText("Por mes");
        checkMes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkMesActionPerformed(evt);
            }
        });

        boxAño.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2006", "2007", "2008" }));

        boxMes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(checkAño)
                    .addComponent(checkMes))
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(boxAño, 0, 60, Short.MAX_VALUE)
                    .addComponent(boxMes, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(checkAño)
                    .addComponent(boxAño, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(checkMes)
                    .addComponent(boxMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(34, Short.MAX_VALUE))
        );

        buttConsultar.setText("Consultar");
        buttConsultar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttConsultarActionPerformed(evt);
            }
        });

        buttSalir.setText("Salir");
        buttSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttSalirActionPerformed(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Tipo Grafica"));

        rb_pastel.setText("Pastel");

        rb_barra.setText("Barra");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rb_pastel)
                    .addComponent(rb_barra))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(rb_pastel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rb_barra)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel1)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(83, 83, 83)
                        .addComponent(buttConsultar)
                        .addGap(27, 27, 27)
                        .addComponent(buttSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(56, 56, 56)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttConsultar)
                    .addComponent(buttSalir))
                .addGap(28, 28, 28))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void buttSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttSalirActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_buttSalirActionPerformed

    private void buttConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttConsultarActionPerformed

        
         porAño = checkAño.isSelected();
         porMes = checkMes.isSelected();
         año = boxAño.getSelectedItem().toString();
         mes = boxMes.getSelectedItem().toString();
         
         Departamento cost = new Departamento();
        String n = cost.ConstruirConsultPorDepartamentos(porAño, porMes, año, mes);
        
        
         
         if(rb_pastel.isSelected()){
         
             cost.CrearGraficoDePastel(n, "Colombia Saludable - Resultados Consulta");
         
         }else if(rb_barra.isSelected()){
         
             cost.CrearGraficoDeBarras(n, "Colombia Saludable - Resultados Consulta", "", "");
         
         }else{
         
             cost.CrearGraficoDeBarras(n, "Colombia Saludable - Resultados Consulta", "", "");
         
         }
        
    }//GEN-LAST:event_buttConsultarActionPerformed

    private void checkAñoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkAñoActionPerformed

        if(checkAño.isSelected()){
        
            boxAño.setEnabled(true);
        
        }else{
        
            boxAño.setEnabled(false);
        
        }
        
        
    }//GEN-LAST:event_checkAñoActionPerformed

    private void checkMesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkMesActionPerformed

        if(checkMes.isSelected()){
            
            boxMes.setEnabled(true);
        
        }else{
        
            boxMes.setEnabled(false);
        }

    }//GEN-LAST:event_checkMesActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox boxAño;
    private javax.swing.JComboBox boxMes;
    private javax.swing.JButton buttConsultar;
    private javax.swing.JButton buttSalir;
    private javax.swing.JCheckBox checkAño;
    private javax.swing.JCheckBox checkMes;
    private javax.swing.ButtonGroup grupoTipo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JRadioButton rb_barra;
    private javax.swing.JRadioButton rb_pastel;
    // End of variables declaration//GEN-END:variables
}
